package Log;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;

public class Log {
	
	static String file; // = "c:\\temp\\log.txt";
	static File logbestand ;
	
	
	public Log(){
		
	}
	public Log (String PathAndFileName){
		if (PathAndFileName == null) return;
		
		try {
			file = PathAndFileName; /* opt null*/
			if (logbestand == null){
				logbestand = new File(file);
				logbestand.createNewFile();
			}
		

		} catch (IOException e) {
			// TODO Auto-generated catch block. NIET BELANGRIJK, LOG
			e.printStackTrace();
			
			System.out.println ("ERROR LOGBESTAND");
		}
	}

	public static void LOG(String message){
		Log L = new Log(file);
		
		if (file == null){
			L.screen(message);
		}
		else{
			L.file(message);
		}
	}
	public static void LOG(String message, int nextRules){
		Log L = new Log(file);
		
		if (file == null){
			L.screen(message);
		}
		else{
			L.file(message);
		}
		
		if ( nextRules <= 0) return;
		
		RULE(nextRules);
		
	}
	
	public static void RULE(){
		//next rule
		// TODO : NIET BELANGRIJK LOG If null then else
		System.out.print("\r");
	}
	public static void RULE(int aantal){
		//next rule
		// TODO : NIET BELANGRIJK LOG  If null then else
		for (int i = 0; i < aantal; i++){
			System.out.print("\r");
		}
	}
	
	private void screen(String message){
		System.out.print(message);
	}
	private void file(String message){
		try {
			PrintWriter pw = new PrintWriter(logbestand);
			pw.append(message + "\r");
			pw.close();

		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block.NIET BELANGRIJK LOG 
			e.printStackTrace();
		}
	}
	
}
